Imports System.Data
Partial Class Client_BrandWiseProducts
    Inherits System.Web.UI.Page
    Dim _bo As New Bo
    Dim brand As String
    Dim cntProduct As Integer
    Dim row, i As Integer
    Dim dt As New DataTable
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        brand = Request.QueryString("Brand")
        lnkNext.Enabled = False
        If Not IsPostBack Then
            ViewState("min") = 1
            ViewState("max") = 6
            dt = _bo.getProductByBrand(ViewState("min"), ViewState("max"), brand)
            DataList.DataSource = dt
            DataList.DataBind()
            cntProduct = _bo.counttotproductBrand(brand)
            If ViewState("min") <= 1 Then
                lnkPrevious.Enabled = False
            End If
            If ViewState("max") < cntProduct Then
                lnkNext.Enabled = True
            End If
        End If
    End Sub
    Protected Sub lnkPrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkPrevious.Click
        _bo.getProductByBrand(ViewState("min"), ViewState("max"), brand).Rows.Clear()
        cntProduct = _bo.counttotproductBrand(brand)
        ViewState("min") = Val(ViewState("min")) - 6
        ViewState("max") = Val(ViewState("max")) - 6
        DataList.DataSource = _bo.getProductByBrand(ViewState("min"), ViewState("max"), brand)
        DataList.DataBind()
        If ViewState("min") <= 1 Then
            lnkPrevious.Enabled = False
        End If
        If ViewState("max") <= cntProduct Then
            lnkNext.Enabled = True
        End If
    End Sub

    Protected Sub lnkNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkNext.Click
        _bo.getProductByBrand(ViewState("min"), ViewState("max"), brand).Rows.Clear()
        cntProduct = _bo.counttotproductBrand(brand)
        ViewState("min") = Val(ViewState("min")) + 6
        ViewState("max") = Val(ViewState("max")) + 6
        DataList.DataSource = _bo.getProductByBrand(ViewState("min"), ViewState("max"), brand)
        DataList.DataBind()
        If ViewState("max") > cntProduct Then
            lnkNext.Enabled = False
        End If
        If ViewState("min") > 1 Then
            lnkPrevious.Enabled = True
        End If
    End Sub
End Class
